<?php

namespace App\Http\Controllers;

use App\Models\ClassModel;
use App\Models\CollegeaModel;
use App\Toor\Tranks;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;

class ClassController extends Tranks
{

    public function classfoteacher(Request $request)
    {
        return rsps('200',ClassModel::with('toTeacher')->find($request),'成功响应');
    }

    public function addclassfoteacher(Request $request)
    {
        ClassModel::find($request['classid'])->toTeacher()->attach([$request['teacherid']]);
        return rsps('200','成功响应','成功响应');
    }

    public function delclassfoteacher(Request $request)
    {
        ClassModel::find($request['classid'])->toTeacher()->detach([$request['teacherid']]);
        return rsps('200','成功响应','成功响应');
    }


    public function classfoStudent(Request $request)
    {
        return rsps('200',ClassModel::with('toStudent')->find($request),'成功响应');
    }

    public function addclassfoStudent(Request $request)
    {
        ClassModel::find($request['classid'])->toTeacher()->attach([$request['teacherid']]);
        return rsps('200','成功响应','成功响应');
    }

    public function delclassfoStudent(Request $request)
    {
        ClassModel::find($request['classid'])->toTeacher()->detach([$request['teacherid']]);
        return rsps('200','成功响应','成功响应');
    }

}
